home *** CD-ROM | disk | FTP | other *** search
/ Internet 53 / INTERNET53.iso / pc / software / windows / building / coldfusion studio evaluation / data1.cab / CFS_Wizards / CFML / Library_FileAction.wml < prev    next >
Encoding:
Text File  |  1998-10-08  |  2.1 KB  |  86 lines

  1. <WIZSET LibraryDirectory = Trim(LibraryDirectory)>
  2. <WIZIF Right( LibraryDirectory, 1 ) EQ '\'>
  3.     <WIZSET LibraryDirectory = Left( LibraryDirectory, Len(LibraryDirectory) - 1 )>
  4. </WIZIF>
  5.  
  6. <!--- parameters --->
  7. <CFSET LibraryDirectory = "$${LibraryDirectory}">
  8. <WIZIF IsOverwriteEnabled
  9. ><CFSET IsOverwriteEnabled = "YES">
  10. <WIZELSE
  11. ><CFSET IsOverwriteEnabled = "NO">
  12. </WIZIF>
  13.  
  14.  
  15. <!--- upload file with unique name --->
  16. <CFFILE
  17.     action="UPLOAD"
  18.     fileField="UploadedFile"
  19.     destination="#LibraryDirectory#\"
  20.     nameConflict="MAKEUNIQUE"
  21. >
  22.  
  23.  
  24. <!--- new name of the uploaded file --->
  25. <CFIF Form.ServerFile is ''>
  26.     <CFSET NewServerFile = File.ClientFile>
  27. <CFELSE>
  28.     <CFSET NewServerFile = Form.ServerFile>
  29. </CFIF>
  30.  
  31.  
  32. <!--- check whether the new file name already exists in the directory --->
  33. <CFDIRECTORY
  34.     name="CheckFile"
  35.     action="LIST"
  36.     directory="#LibraryDirectory#\"
  37.     filter="#NewServerFile#"
  38. >
  39. <CFIF CheckFile.RecordCount is 0
  40.     or File.ClientFile is File.ServerFile>
  41.     <CFSET FileAlreadyExists = "NO">
  42. <CFELSE>
  43.     <CFSET FileAlreadyExists = "YES">
  44. </CFIF>
  45.  
  46.  
  47. <HTML><HEAD>
  48.     <TITLE>$${ApplicationName} - File Received</TITLE>
  49. </HEAD><BODY bgcolor="ffffff">
  50.  
  51. <FONT size="+1">$${ApplicationName}</FONT> <BR>
  52.  
  53. <!--- if file name already exists and overwrite is allowed delete file and throw an error --->
  54. <CFIF FileAlreadyExists and not IsOverwriteEnabled>
  55.  
  56.     <!--- delete file --->
  57.     <CFSET TempFilePath = "#LibraryDirectory#\#File.ServerFile#">
  58.     <CFFILE
  59.         action="DELETE"
  60.         file="#TempFilePath#"
  61.     >
  62.  
  63.     <FONT size="+2" color="ff0000"><B>File Already Exists</B></FONT>
  64.     <P>
  65.     Press Back button and use different file name.
  66.  
  67. <!--- ... else rename the file --->
  68. <CFELSE>
  69.  
  70.     <!--- rename file --->
  71.     <CFSET SourceName = LibraryDirectory & '\' & File.ServerFile>
  72.     <CFSET DestinationName = LibraryDirectory & '\' & NewServerFile>
  73.     <CFFILE
  74.         action="RENAME"
  75.         source="#SourceName#"
  76.         destination="#DestinationName#"
  77.     >    
  78.  
  79.     <FONT size="+2"><B>File Received</B></FONT>
  80.     <P>
  81.     File was successfully received.
  82.     <P>
  83.     [<A href="$${SafeApplicationName}_FileLibrary.cfm">Library</A>]
  84. </CFIF>    
  85.  
  86. </BODY></HTML>